package com.lu.pojo.functionInterface;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

/**
 * @author luzhenfang
 * @date 2020 07 13
 * @description 生产者接口
 */
public class Support {
    public static void main(String[] args) {
        List<Integer> numList = getNumList(30, () ->(int)(Math.random()*100));
        for (Integer integer : numList) {
            System.out.println(integer);
        }
        System.out.println("----------------");
         numList.stream().filter(e -> e > 90)
                 .collect(Collectors.toList())
                 .forEach(System.out::println);

    }

    public static List<Integer> getNumList(int num, Supplier<Integer> sup) {
        List<Integer> integers = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            Integer integer = sup.get();
            integers.add(integer);
        }
        return integers;
    }
}
